<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分析历史记录</title>
    <style>
        :root {
            --primary: #3b82f6;
            --success: #10b981;
            --warning: #f59e0b;
            --danger: #ef4444;
            --gray: #64748b;
        }
        * { box-sizing: border-box; margin: 0; padding: 0; }
        body {
            font-family: 'Segoe UI', Arial, sans-serif;
            line-height: 1.6;
            color: #1f2937;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        header { margin-bottom: 30px; }
        h1 { color: var(--primary); font-size: 28px; margin-bottom: 10px; }
        .subtitle { color: var(--gray); font-size: 18px; }

        /* 导航链接 */
        .nav-link {
            margin-bottom: 20px;
        }
        .nav-link a {
            color: var(--primary);
            text-decoration: none;
            font-size: 16px;
        }
        .nav-link a:hover { text-decoration: underline; }

        /* 表格样式 */
        .table-container {
            background-color: white;
            border-radius: 12px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            overflow: hidden;
        }
        table {
            width: 100%;
            border-collapse: collapse;
        }
        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #e2e8f0;
        }
        th {
            background-color: #f8fafc;
            color: var(--gray);
            font-weight: 600;
        }
        tr:hover { background-color: #f8fafc; }

        /* 状态标签 */
        .status {
            padding: 3px 8px;
            border-radius: 4px;
            font-size: 14px;
            font-weight: 500;
        }
        .status-processing { background-color: #fef3c7; color: #d97706; }
        .status-completed { background-color: #dcfce7; color: #166534; }
        .status-failed { background-color: #fecdd3; color: #b91c1c; }

        /* 空状态 */
        .empty-state {
            text-align: center;
            padding: 60px 20px;
            background-color: white;
            border-radius: 12px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }
        .empty-icon { font-size: 48px; color: #cbd5e1; margin-bottom: 15px; }
        .empty-text { color: var(--gray); margin-bottom: 20px; }

        /* 按钮 */
        .btn {
            background-color: var(--primary);
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 6px;
            cursor: pointer;
            text-decoration: none;
            font-size: 14px;
            transition: background-color 0.3s;
        }
        .btn:hover { background-color: #2563eb; }
        .btn-success { background-color: var(--success); }
        .btn-success:hover { background-color: #059669; }
    </style>
</head>
<body>
    <header>
        <div class="nav-link">
            <a href="/">← 返回首页</a>
        </div>
        <h1>分析历史记录</h1>
        <p class="subtitle">查看和管理过往的产品设计思维分析记录</p>
    </header>

    {% if records and records|length > 0 %}
        <div class="table-container">
            <table>
                <thead>
                    <tr>
                        <th>视频文件</th>
                        <th>文件大小（MB）</th>
                        <th>分析时间</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for record in records %}
                        <tr>
                            <td>
                                <div>{{ record.filename }}</div>
                                <div style="font-size: 12px; color: var(--gray);">ID: {{ record.id[:8] }}...</div>
                            </td>
                            <td>{{ record.file_size }}</td>
                            <td>{{ record.upload_time.strftime('%Y-%m-%d %H:%M') }}</td>
                            <td>
                                {% if record.status == 'processing' %}
                                    <span class="status status-processing">处理中</span>
                                {% elif record.status == 'completed' %}
                                    <span class="status status-completed">分析完成</span>
                                {% else %}
                                    <span class="status status-failed">分析失败</span>
                                {% endif %}
                            </td>
                            <td>
                                {% if record.status == 'completed' %}
                                    <a href="/analysis/{{ record.id }}" class="btn">查看结果</a>
                                    <a href="/export_analysis/{{ record.id }}" class="btn btn-success">导出</a>
                                {% elif record.status == 'processing' %}
                                    <span style="color: var(--gray);">处理中</span>
                                {% else %}
                                    <a href="/" class="btn">重新分析</a>
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    {% else %}
        <div class="empty-state">
            <div class="empty-icon">📁</div>
            <h3 class="empty-text">暂无分析记录</h3>
            <p class="empty-text">您还没有进行过产品设计思维分析</p>
            <a href="/" class="btn">上传视频开始分析</a>
        </div>
    {% endif %}
</body>
</html>